<?
        require_once '../inc/functions.php';
        require_once dirname(__FILE__) . '/data.php';
        require_once dirname(__FILE__) . '/../Users/data.php';
        require_once dirname(__FILE__) . '/../Lookups/data.php';
        $section='Users';
        
        if(isset($_REQUEST['PName']))
        {
                $rs = $_REQUEST;
                $errors = Validate($rs);
                if(!$errors)
                        $errors = Save($rs);
                if(!$errors)
                {
                        header("Location: index.php?new_id=$rs[id]");
                }
        }
        elseif(isset($_REQUEST['id']))
                $rs = Get($_REQUEST['id']);
        else
                $rs = Blank();

	
                
        $resultsUesrs = Users::GetAll();
        $resultsLookups = Lookups::GetAll();
?>

<!DOCTYPE html>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Users</title>
        <style type="text/css">
                        .error { color: red; }
                        input.error {
                                border: 1px solid red;
                                background: #FEE;
                        }
                </style>
    </head>
    
    <body>
    
                <? include("../inc/tabs.php"); ?>
                <div id="container">
        
        <h1>Add a Product</h1>
        <ul class="error">
                <? foreach($errors as $field => $error){ ?>
                <li><?=$field?>: <?=$error?></li>
            <? } ?>
        </ul>
        
    <form method="post" action="">
                <label>id:</label>
                <?=$rs['id']?>
            <br />     
	
<label for="PName">Product Name</label>
                <input  type="text"
                        name="PName" id="PName"
                    value="<?=$rs['PName']?>"
                    class="<?=isset($errors['Name']) ? 'error' : '' ?>" />
            <span class="error"><?=$errors['Name']?></span>
            <br />
<label for="Description">Description</label>
                <input  type="text"
                        name="Description" id="Description"
                    value="<?=$rs['Description']?>"
                    class="<?=isset($errors['Description']) ? 'error' : '' ?>" />
            <span class="error"><?=$errors['Description']?></span>
            <br />

	<label for="Supplier">Supplier</label>
                <input  type="text"
                        name="Supplier" id="Supplier"
                    value="<?=$rs['Supplier']?>"
                    class="<?=isset($errors['Supplier']) ? 'error' : '' ?>" />
            <span class="error"><?=$errors['Supplier']?></span>
            <br />
            
      <label for="Price">Price</label>
                <input  type="text"
                        name="Price" id="Price"
                    value="<?=$rs['Price']?>"
                    class="<?=isset($errors['Price']) ? 'error' : '' ?>" />
            <span class="error"><?=$errors['Price']?></span>
            <br />



            <input type="submit" value="Save" />
        </form>
        </div>
        </body>
</html>
